﻿using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using PmSoft.Entity;
using System.ComponentModel;

namespace Modules
{
    /// <summary>
    /// 建设单位-指挥部信息
    ///</summary>
    [TableName("commander")]
    [Description("建设单位-指挥部信息")]
    [PrimaryKey("commander_id", AutoIncrement = true)]
    [CacheSetting(true)]
    [Serializable]
    public class CommanderInfo : IEntity, IProjectUser
    {
        /// <summary>
        /// 指挥部ID
        ///</summary>
        [Column("commander_id")]
        public int CommanderId { get; set; }

        /// <summary>
        /// 指挥部名称
        ///</summary>
        [Column("name")]
        public string Name { get; set; }

        /// <summary>
        /// 所属建设单位ID
        ///</summary>
        [Column("constructor_id")]
        public int ConstructorId { get; set; }

        /// <summary>
        /// 指挥者名称
        ///</summary>
        [Column("leader")]
        public string Leader { get; set; }

        /// <summary>
        /// 指挥者手机号码
        ///</summary>
        [Column("mobile")]
        public string Mobile { get; set; }

        /// <summary>
        /// 指挥者身份证号码
        ///</summary>
        [Column("cardno")]
        public string Cardno { get; set; }

        /// <summary>
        /// 安全信息ID
        ///</summary>
        [Column("security_id")]
        public int SecurityId { get; set; }

        /// <summary>
        /// 创建时间
        /// 默认值: CURRENT_TIMESTAMP
        ///</summary>
        [Column("create_time")]
        public DateTime? CreateTime { get; set; }

        /// <summary>
        /// 默认项目ID
        /// </summary>
        [Column("project_id")]
        public int ProjectId { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return this.CommanderId; } }

        #endregion IEntity 成员

        #region IUser

        [Ignore]
        string IUser.Name => this.Name;

        [Ignore]
        int IUser.Id => this.CommanderId;

        [Ignore]
        UserType IUser.Type => UserType.Commander;

        [Ignore]
        int? IProjectUser.ProjectId => this.ProjectId;

        #endregion IUser
    }
}